<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
	</head>

	<body>
		<div class="pageContent">
			<div class="panelBar">
				<ul class="toolBar">
<%-- 					<li><a href="${pageContext.request.contextPath }/UserPhoneAjax?opt=createNote" rel="up_id" target="selectedTodo" class="add" title="确定要生成通讯录吗？"><span>生成通讯</span></a></li> --%>
					<li><a href="${pageContext.request.contextPath }/UserPhoneAjax?opt=createNote" class="add" id="nl_create"><span>生成通讯</span></a></li>
					<li><a href="${pageContext.request.contextPath }/UserPhoneAjax?opt=delfromNote" rel="up_id" target="selectedTodo" class="delete" title="确定要移除吗？"><span>移除联系人</span></a></li>
				</ul>
			</div>
			<c:choose>
				<c:when test="${empty note}">
					<div>
						<h1>通讯录空空如也!</h1>			
					</div>
				</c:when>
				<c:otherwise>
					<table class="table" width="98%" layoutH="85">
						<thead>
							<tr>
								<th width="50">序号</th>
								<th width="30"><input type="checkbox" class="checkboxCtrl" group="up_id"></th>
								<th width="150">姓名</th>
								<th width="150">手机号码</th>
								<th width="150">部门</th>
								<th>备注</th>
							</tr>
						</thead>
						<tbody id="nl_users">
							<c:forEach items="${note }" var="up" varStatus="i">
								<tr>
									<td>${i.count }</td>
									<td><input type="checkbox" name="up_id" value="${up.id }"></td>
									<td>${up.u_name }</td>
									<td>${up.u_phoneno }</td>
									<td>${up.dept.d_name }</td>
									<td></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</c:otherwise>
			</c:choose>
		</div>
		
		<script type="text/javascript">
			$(function(){
				$("#nl_create").click(function(){
					var len = $("#nl_users :checked").size();
					if(len == 0){
						alertMsg.error("请选择联系人!");
						return false;
					}else{
						var ids = "";
						$("#nl_users :checked").each(function(i,n){
							ids = ids+","+$(this).val();
						});
						ids = ids.substring(1);
						var href = $("#nl_create").attr("href");
						if(href.match("&ids")){
							href = href.substring(0,href.indexOf("&ids"));
						}
						href = href + "&ids="+ids;
						 $("#nl_create").attr("href",href);
						return true;
					}
				});
			});
		</script>
	</body>

</html>